package team.pwy.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import team.pwy.pojo.entity.Session;
import team.pwy.service.SeatService;
import team.pwy.service.SessionService;
import team.pwy.vo.Result;

import java.util.List;

@RestController
@RequestMapping("session")
public class SessionController {
    @Autowired
    private SessionService sessionService;

    @Autowired
    private SeatService seatService;

    @GetMapping()
    public Result findBySessionId(Integer id) {
        Session session = sessionService.findBySessionId(id);
        return session.getNumber() > 0 ? new Result("200", "查询场次成功",session) : new Result("400", "没有空座");
    }
    @GetMapping("findMovieId")
    public Result findByMovieId(Integer movieId,String time){
        List<Session> session = sessionService.findByMovieId(movieId,time);
        return session == null ? new Result("400","查询失败"):new Result("200","查询场次成功",session);
    }

/*    @GetMapping("{hallId}")
    public Result findByHallId(@PathVariable Integer hallId) {
        Session session = sessionService.findByHallId(hallId);
//        seatService
        return session == null ? new Result("400", "查询失败") : new Result("200", "查询场次成功", session);
    }*/
}
